package cn.edu.sju;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class work05
{
    
    public static void main(String[] args)
    {
        try {
            FileWriter fw=new FileWriter("C:\\myDoc\\hello.txt");
            BufferedWriter bw=new BufferedWriter(fw);
            bw.write("大家好");
            bw.newLine();
            bw.write("再见");
            bw.flush();
            bw.close();
            fw.close();
        }
        catch(IOException e) {
            System.out.println("文件不存在");
        }
        try {
            FileReader fr=new FileReader("C:\\myDoc\\hello.txt");
            BufferedReader br=new BufferedReader(fr);
            String line =br.readLine();
            while(line!=null) {
                System.out.println(line);
                line=br.readLine();             
            }
            br.close();
            fr.close();
            System.out.println("wys");
        }
        catch(IOException e) {
            System.out.println("文件不存在！");
        }
        
    }
    
}
